package com.nave.princesslife.jogogenius;

import com.nave.princesslife.activities.StoreActivity;
import com.nave.princesslife.main.Data;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;

public class GeniusActivity extends Activity implements Runnable {

	Context c;
	Game g;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		// Sem Activity e em modo Fullcreen.
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

		Game g = new Game(this);
		c = getApplicationContext();

		if (g.tempo == 0) {

			Toast.makeText(c, "Fim de jogo", Toast.LENGTH_LONG).show();

			/*
			 * if(g.pontos >20) Toast.makeText(c, "Voce ganhou!!",
			 * Toast.LENGTH_LONG).show();
			 * 
			 * else{ Toast.makeText(c, "Voce perdeu", Toast.LENGTH_LONG).show();
			 * }
			 */

		}

		View game = new Game(this);
		setContentView(game);
	}

	@Override
	public void run() {
		// TODO Auto-generated method stub
		while (true) {
			try {
				Thread.sleep(100);

			} catch (Exception e) {
				Log.e("Jogo", "Sleep da Thread");
			}

			if (g.tempo == 0) {

				if (g.pontos > 20) {
					Data.getInstance().setMoney(100);
					Intent intent = new Intent(this, StoreActivity.class);
					startActivity(intent);

				} else {
					Intent intent = new Intent(this, StoreActivity.class);
					startActivity(intent);

				}

			}
		}

	}

}
